The invention relates to computer graphics. More particularly, it relates to rendering of a computer generated image.
Computer systems are used to render all kinds of images for display. In general, it is important that images rendered for display appear as realistic to a viewer as possible. It is also important in many applications that the computer system used to render images for display operate at an interactive rate.
Many computer systems used to render images for display have graphics processors such as the NVIDIA GEFORCE3 graphics processor, available from NVIDIA Corporation, Santa Clara, Calif., and the ATI RADEON 8500 graphics processor, available from ATI Technologies, Incorporated, Canada. These graphics processors support multiple texture units. These graphics processors also allow for flexibility in the configuration of the per-pixel computation stage of their graphics rendering pipeline. This makes it possible to implement, at interactive rates, complex algorithms for combining, blending, and/or modulating multiple textures in a single pass through the graphics rendering pipeline.
One technique for combining or blending two textures involves using a fragment value from one texture as a weight in the blending of fragment values from two other textures. While this technique is useful in many instances, it has limitations. For example, it cannot be used to blend three or more textures in a single pass through a graphics rendering pipeline. It also cannot blend three or more textures using a single texture as a mask. U.S. Pat. No. 6,373,482 to Migdel et al., issued Apr. 16, 2002, describes a technique for modifying the blending between two clip-map tiles (i.e., textures). This technique also has limitations such as, for example, it cannot blend three or more clip-map tiles using a single texture as a mask.
What is needed are new techniques for combining, blending, and/or modulating more than two textures at an interactive rate, which can be implemented in a single pass through a graphics rendering pipeline.
The present invention provides a method, a system, and a computer program product for blending a variable number of textures using a single texture as a mask. At least a first texture, a second texture, a third texture, and a fourth texture are used to form a blended image. Masks are extracted from one of the textures. The other textures are blended together in accordance with the extracted masks to form the blended image.
In one embodiment of the invention, Nxe2x88x922 masks are extracted from the first texture of N textures, wherein N is a number equal to at least four. The second texture and the third texture of the N textures are blended in accordance with one of the Nxe2x88x922 masks to form the blended image. Another texture of the N textures is blended with the blended image in accordance with another one of the Nxe2x88x922 masks. In a similar manner, other textures of the N textures are blended with the blended image in accordance with other ones of the Nxe2x88x922 masks until all of the N textures, except for the first texture, have been blended together. The Nxe2x88x922 masks can be extracted, for example, from an intensity texture, an RGB texture, or an RGBxcex1 texture. The first texture can be, for example, scaled or scaled and biased to form at least one of the Nxe2x88x922 masks.
In another embodiment of the invention, at least a first mask, a second mask, and a third mask are extracted from the first texture. The second texture is multiplied by the first mask to form a first image. A third texture is multiplied by the second mask to form a second image. A fourth texture is multiplied by the third mask to form a third image. At least the first image, the second image, and the third image are added to form the blended image. In an embodiment, the first mask and the second mask are added and the result unsigned-inverted to form the third mask.
In embodiments of the invention, the textures that are blended together each have a red color channel, a green color channel, and a blue color channel, and these color channels are uniformly blended to form the blended image. In other embodiments, the textures that are blended together each have a red color channel, a green color channel, and a blue color channel, and these color channels are non-uniformly blended to form the blended image.
In an embodiment, the present invention is used to blend between consecutive roaming levels in a cliptexture emulation scheme. It is an advantage of the invention that any texture can be used. It is also an advantage of the invention that embodiments can be implemented using the processing capabilities of available graphics processors.
Further features and advantages of the present invention, as well as the structure and operation of various embodiments of the present invention, are described in detail below with reference to the accompanying drawings.